#include "widget.h"
#include "PixmapWidget/pixmapwidget.h"
#include "PixmapButton/pixmapbutton.h"
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    m_pixmap_widget = new PixmapWidget(":/png/resource/login_dialog.png", 0, 0);
    m_pixmap_widget->show();

    m_pixmap_button_1 = new PixmapButton(":/png/resource/confirm_button_released.png", ":/png/resource/confirm_button_pressed.png", 0, 0, this);
    m_pixmap_button_1->move(50, 50);
    m_pixmap_button_2 = new PixmapButton(":/png/resource/confirm_button_released.png", ":/png/resource/confirm_button_pressed.png",
                                      ":/png/resource/confirm_button_background.png", 0, 0, this);
    m_pixmap_button_2->move(300, 50);

    m_pixmap_button_3 = new PixmapButton(this);
    m_pixmap_button_3->resize(100, 50);
    m_pixmap_button_3->move(550, 50);

    m_multi_select_box = new MultiSelectComboBox(this);
    m_multi_select_box->move(550, 150);
//    m_multi_select_box->resize(300, m_multi_select_box->size().height());
    m_multi_select_box->resize(300, 40);
    m_multi_select_box->setPlaceHolderText("图例选择");
    addComboBoxItems();
    qDebug() << m_multi_select_box->currentItems();
    connect(m_multi_select_box, &MultiSelectComboBox::selectedChange,
            this, [=](const QString item, bool checked){
        qDebug() << item << " | " << checked;
        QPen pen;
        m_multi_select_box->getItemAttr(item, pen);
        qDebug() << pen.color() << " | " << pen.style();});
    connect(m_pixmap_button_1, &PixmapButton::clicked, this, &Widget::addComboBoxItems);
    connect(m_pixmap_button_2, &PixmapButton::clicked, m_multi_select_box, &MultiSelectComboBox::clear);
//    connect(m_pixmap_button_2, &PixmapButton::clicked, m_multi_select_box, &QComboBox::clear);

    m_check_box_widget = new CheckBoxWidget(this);
    m_check_box_widget->move(700, 50);
    m_check_box_widget->setText("check_box_widget");
    m_check_box_widget->setSize(300, 60);
    m_check_box_widget->setColor();
    connect(m_check_box_widget, &CheckBoxWidget::stateChanged, this, &Widget::display);
}

Widget::~Widget()
{
}
void Widget::addComboBoxItems()
{
    m_multi_select_box->addItem("透过率");
    m_multi_select_box->addItem("发射率");
    m_multi_select_box->addItem("漫反射率");
}
void Widget::display(int count)
{
    qDebug() << count;
}
